package com.isdust.jy.mbank.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * Created by zor on 2016/10/14.
 */

public abstract class BaseAdapter<T> extends android.widget.BaseAdapter{
    protected Context context;
    protected LayoutInflater inflater;
    protected List<T>tList = new ArrayList<>();





    @Override
    public int getCount() {
        return tList.size();
    }

    @Override
    public Object getItem(int i) {
        return tList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    abstract public View getView(int i, View view, ViewGroup viewGroup);

    @Override
    public boolean isEmpty() {
        return tList.isEmpty();
    }

    public void addItems(List<T>tList){
        this.tList.addAll(tList);
        notifyDataSetChanged();
    }
    public void setItems(List<T>tList){
        this.tList.clear();
        this.tList = tList;
        notifyDataSetChanged();
    }
    public void clear(){
        tList.clear();
        notifyDataSetChanged();
    }
}
